  <script>
    $(function() {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
        $( "#dialog-form" ).dialog({
            autoOpen: false,
            width:500,
            height: 400,
            resizable: true,
            draggable: false
        });

        /*$( ".edit" ).click(function() {
            $.ajax({
                url:$(this).attr('href'),
                success:function(data) {
                    var data = $.parseJSON(data);
                    $('#dialog-form').html(data.html);
                    $('#dialog-form').dialog('option',{
                        title: data.title,
                        position: 'center'
                    });
                    $('#dialog-form').dialog('open');
                }
            });
            return false;
        });*/
    });
    //$("#dialog-form").css('margin-top',-1($("dialog-form").height()/2));
  </script>
  
<div id="ticket_list">

  <div class='title-division'><h3>
  <form action="<?php echo site_url('phongmay');?>" method="post" id="form_pm">
    Chọn tên phòng máy để xem dánh sách máy tính: <select name="pm" style="width: 100px;" onchange="document.forms['form_pm'].submit();">
        <?php if(!empty($listpm))
        {
            foreach($listpm as $keypm =>$valuepm){
                if($this->input->post('pm')==$keypm) echo '<option selected="selected" value="'.$keypm.'">'.$valuepm.'</optiion>';
                else echo '<option value="'.$keypm.'">'.$valuepm.'</optiion>';
            }
        }
        ?>
    </select>
  </form></h3>
</div>
<?php if(!empty($listmt)):?>
    <br />
    <h3>Danh sách máy tính của phòng máy "<?php echo ($this->input->post('pm')?$listpm[$this->input->post('pm')]:$listpm[1]);?>"</h3>
  <table class='listing tickets sortable one-table' id='group_by_milestone_id_iPhone_App_Phase_I_Final_Tweaks'>
  <thead>
    <tr>
      <th class="sorttable_numeric">STT</th>
        <th class="sorttable_alpha">Máy tính</th>
        <?php if(!empty($listllkmt))
        foreach($listllkmt as $keylkmt=>$vallkmt){
            echo '<th class="sorttable_alpha">'.$vallkmt.'</th>';
        }
        ?>
        <th class="sorttable_alpha">Thao tác</th>
    </tr>
  </thead>
  <tbody>  
    <?php    
                $i=1;
                foreach($listmt as $keymt=>$mt)
                {
                    $class_tr = ($i%2)?'color4-even':'color3-odd';
       ?>
                    <tr class="<?php echo $class_tr;?> navlink">
                        <td class="number"><?php echo $i;?></td>
                        <td><?php echo $mt['ten']?></td>
                        <?php if(!empty($listllkmt)){
                            foreach($listllkmt as $keyllkmt=>$valllkmt){
                                echo '<td>';//.$keyllkmt.' '.$valllkmt;//var_dump($mt[$keylkmt]);
                                if(!empty($mt[$keyllkmt])){
                                    foreach($mt[$keyllkmt] as $ctmt){
                                        echo $ctmt.'<br />';
                                    }
                                }
                                echo '</td>';
                            }
                        }
                        ?>
                        <td>
                            <a class="edit" href="<?php echo site_url($_siteurlkeys['phongmay_suamt'].'/'.$keymt);?>" style="width: 16px; float: left;padding-right: 5px;"><img src="<?php echo site_url('images/ico-edit.png');?>"   border="0" title="Sửa"/></a> &nbsp;&nbsp;
                            <a href="<?php echo site_url($_siteurlkeys['phongmay_xoamt'].'/'.$keymt);?>" onclick="return confirm('Bạn thật sự muốn xóa không?')" style="width: 16px; float: left;" ><img src="<?php echo site_url('images/delete.png');?>" border="0" title="Xóa"/></a>
                        </td>                    
                    </tr>
                
       <?php
        $i++;    
        }
        //if(!empty())                                                                                                                                  
        ?>
      </tbody> 
  </table>
  
  <br />
  <h3>Danh sách các thiết bị của phòng máy "<?php echo ($this->input->post('pm')?$listpm[$this->input->post('pm')]:$listpm[1]);?>"</h3>
  <?php            
            if(count($listtbpm)>0)
            {?>
            <table class='listing tickets sortable one-table'>
                <tr>
                    <th class="sorttable_numeric">STT</th>
                    <th class="sorttable_alpha">Tên thiết bị</th>
                    <th class="sorttable_alpha">Nhà sản xuất</th>
                    <th class="sorttable_alpha">Mô tả</th>
                    <th class="sorttable_alpha">Trạng thái</th>
                    <th class="sorttable_alpha">Thao tác</th>
                </tr>    
       <?php    
                $i=1;
                foreach($listtbpm as $tb)
                {
                    $class_tr = ($i%2)?'color4-even':'color3-odd';
       ?>
                    <tr class="<?php echo $class_tr;?> navlink">
                        <td class="number"><?php echo $i;?></td>
                        <td><?php echo $tb->tb_name;?></td>
                        <td><?php echo $tb->tb_nsx;?></td>
                        <td><?php echo $tb->tb_desc;?></td>
                        <td><?php echo (!empty($trangthaitb[$tb->tt_id])? $trangthaitb[$tb->tt_id]:'Chưa biết');
                                        /*if($tb->tt_id==1)
                                        {
                                            echo 'Tốt';
                                        }elseif($tb->tt_id==2)
                                            echo 'Hư';
                                        else
                                        {
                                            echo 'Cho mượn';
                                        }*/
                                ?>                                                
                        </td>   
                        <td>
                            <a class="edit" href="#" style="width: 16px; float: left;padding-right: 5px;"><img src="<?php echo site_url('images/ico-edit.png');?>" border="0" title="Sửa"/></a> &nbsp;&nbsp;
                            <a href="<?php echo site_url(''.$tb->tb_id);?>" style="width: 16px; float: left;" ><img src="<?php echo site_url('images/delete.png');?>" border="0" title="Xóa"/></a>
                        </td>                    
                    </tr>
       <?php    
                    $i++;    
                }        ?>
              </table>
        <?php                                                  
            }
  ?>    
  <br />
  <h3>Danh sách linh kiện dự phòng của phòng máy "<?php echo ($this->input->post('pm')?$listpm[$this->input->post('pm')]:$listpm[1]);?>"</h3>
  <?php if(count($listlkpm)>0)
            {?>
            <table class='listing tickets sortable one-table'>
                <tr>
                    <th class="sorttable_numeric">STT</th>
                    <th class="sorttable_alpha">Tên linh kiện</th>
                    <th class="sorttable_alpha">Loại linh kiện</th>
                    <th class="sorttable_alpha">Số lượng</th>
                    <th class="sorttable_alpha">Mô tả</th>
                    <th class="sorttable_alpha">Trạng thái</th>
                    <th class="sorttable_alpha">Thao tác</th>
                </tr>    
       <?php    
                $i=1;
                foreach($listlkpm as $lk)
                {
                    $class_tr = ($i%2)?'color4-even':'color3-odd';
       ?>
                    <tr class="<?php echo $class_tr;?> navlink">
                        <td class="number"><?php echo $i;?></td>
                        <td><?php echo $lk->lk_name;?></td>
                        <td><?php echo (!empty($listllkmt[$lk->llk_id])?$listllkmt[$lk->llk_id]:'');?></td>
                        <td><?php echo $lk->soluong;?></td>
                        <td><?php echo $lk->lk_desc;?></td>
                        <td><?php echo (!empty($trangthaitb[$lk->tt_id])? $trangthaitb[$lk->tt_id]:'Chưa biết');?>                                                
                        </td>   
                        <td>
                            <a class="edit" href="#" style="width: 16px; float: left;padding-right: 5px;"><img src="<?php echo site_url('images/ico-edit.png');?>" border="0" title="Sửa"/></a> &nbsp;&nbsp;
                            <a href="<?php echo site_url(''.$lk->lk_id);?>" style="width: 16px; float: left;" ><img src="<?php echo site_url('images/delete.png');?>" border="0" title="Xóa"/></a>
                        </td>                    
                    </tr>
       <?php    
                    $i++;    
                }        ?>
              </table>
        <?php                                                  
        }  
        ?>
  <?php else: echo 'Đang cập nhật dữ liệu';?>
  <?php endif;?>
  
  
  <?php if(!empty($dataform)) echo $dataform;?>
</div>